<template>
    <div class="city">
        <CityHeader></CityHeader>
        <Search :list="cities"></Search>
        <List :hot="hotCity" :letter="letter" :list="cities"></List>
        <Alphabet @chang="handleLetterChang" :list="cities"></Alphabet>
    </div>
</template>
<script type="text/javascript">
    export default {
    data () {
        return {
            cities:{}, // 城市列表
            hotCity:[], //热门城市
            letter: ''  // A-Z
        }
    },
    components: {
        CityHeader,
        Search,
        List,
        Alphabet
    },
    methods:{
        getCityInfo () {
            axios.get('/api/city.json').then(this.getCityInfoSucc)   //请求本地配置的mock数据
        },
        getCityInfoSucc(res){
             res = res.data
            if (res.ret && res.data) {
                const data = res.data
                this.hotCity = data.hotCities
                this.cities = data.cities
            }
        }
    },
    mounted () {
        this.getCityInfo ()
    }
}
</script>

